package com.epam.facebook_client.manager;

import java.io.File;
import java.io.IOException;

import android.content.Context;
import android.graphics.Bitmap;

import common.managers.AbstractImageManager;
import common.utils.MD5Util;

public class ImageManager extends AbstractImageManager {

	public static final String TAG = ImageManager.class.getSimpleName();
	public static final String SERVICE_NAME = "--IMAGE_MANAGER--";

	private static final int SIZE_MEM_CACHE = 4 * 1024 * 1024;
	private static final int POOL_SIZE = 3;

	public ImageManager(Context context) {
		super(context, SIZE_MEM_CACHE, POOL_SIZE);
	}

	public static ImageManager get(Context context) {
		return (ImageManager) context.getApplicationContext().getSystemService(SERVICE_NAME);
	}

	@Override
	public Bitmap loadBitmap(String url) throws IOException {
		return HttpClientManager.get(getContext()).loadAsBitmap(url);
	}

	@Override
	public String getPathCacheDir(String url) {
		return getContext().getCacheDir().getAbsolutePath() + File.separator + MD5Util.getInstance().md5(url);
	}

}
